package cn.com.simple.learning.mybatisplus.service;

import cn.com.simple.learning.core.entity.User;
import cn.com.simple.learning.mybatisplus.mapper.UserMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author Jianxing.Jia
 * @date 2022/1/28
 * @description 批量添加
 */
@Service
public class UserService extends ServiceImpl<UserMapper, User> {

	@Transactional(rollbackFor = Exception.class)
	public Integer batchSave(List<User> users) {
		if (CollectionUtils.isEmpty(users)) {
			return 0;
		}
		return this.baseMapper.insertBatchSomeColumn(users);
	}

}
